from utils.webdriver_factory import WebDriverFactory

driver = WebDriverFactory.get_instance()

# 获取所有cookie
driver.get('http://www.baidu.com')
cookie_list = driver.get_cookies()
print(cookie_list)

# 添加cookie
# name:cookie的名称  value:cookie的值
driver.add_cookie({
    'name': 'user',
    'value': 'mock-user'
})

cookie_list = driver.get_cookies()
print(cookie_list)

# 获取指定cookie的值
user = driver.get_cookie('user')
print(user)


# 删除cookie
driver.delete_cookie('user')
# user = driver.get_cookie('user') None

# 删除所有cookie
driver.delete_all_cookies()